import {useSelector,useDispatch} from 'react-redux'
import {addCountSync,subCountSync} from '@/store/modules/counterSlice'
export default ()=>{
    const count=useSelector(state=>{
        return state.counterKey.count
    })
    const dispatch=useDispatch()
    return (<>
        <h1>RTK版的计数器</h1>
        <div>{count}</div>
        <button onClick={()=>{
            dispatch(addCountSync(3))
        }}>+</button>
        <button onClick={()=>{
            dispatch(subCountSync(2))
        }}>-</button>
    </>)
}